----------------------------------------------------------------------------------------------------------------------------------
--[[

    

]]--
----------------------------------------------------------------------------------------------------------------------------------
-- 
----------------------------------------------------------------------------------------------------------------------------------
local hutao_com_level_sys = Class(function(self, inst)
    self.inst = inst
    self.classified = nil
    self.data = {}
end)
------------------------------------------------------------------------------------------------------------------------------
--- classified
    function hutao_com_level_sys:AttachClassified(classified)
        self.classified = classified
        classified:ListenForEvent("level_com_update",function()
            local new_data = classified:GetLevelData()
            if new_data then
                self.data = new_data
            end
            self.inst:PushEvent("hutao_com_level_sys_update")
        end)
        print("hutao_com_level_sys:AttachClassified")
    end
------------------------------------------------------------------------------------------------------------------------------
--- 部分数据传送
    function hutao_com_level_sys:GetRPC()
        return self.inst.replica.hutao_com_rpc_event or self.inst.replica._.hutao_com_rpc_event
    end
    function hutao_com_level_sys:SyncData(data)
        if self.classified then
            self.classified:SetLevelData(data)
        else
            print("error : hutao_com_level_sys:SyncData classified is nil")
        end
    end
    function hutao_com_level_sys:ForceSyncData()
        local rpc = self:GetRPC()
        if rpc then
            rpc:PushEvent("hutao_com_level_sys.SyncData.server")
        end
    end
------------------------------------------------------------------------------------------------------------------------------
--- 数据读取
    function hutao_com_level_sys:GetData(index)
        return self.data[index]
    end
------------------------------------------------------------------------------------------------------------------------------
--- 等级锁
    function hutao_com_level_sys:CanLevelUp()
        local level_up_locker = self.data.level_up_locker or {}
        return not level_up_locker[self:GetLevel()]
    end
    function hutao_com_level_sys:IsLevelUpLocking()
        local level_up_locker = self.data.level_up_locker or {}
        if level_up_locker[self:GetLevel()] and self:GetExp() > self:GetExpMax() then
            return true
        end
        return false
    end
------------------------------------------------------------------------------------------------------------------------------
--- 突破
    function hutao_com_level_sys:LevelUpBreak()
        local rpc = self:GetRPC()
        if rpc then
            rpc:PushEvent("hutao_com_level_sys.LevelUpBreak.server")
        end
    end
------------------------------------------------------------------------------------------------------------------------------
--- 等级相关
    function hutao_com_level_sys:SetLevel(level)
        if self.classified then
            self.classified:SetLevel(level)
        end
    end
    function hutao_com_level_sys:GetLevel()
        if self.classified then
            return self.classified:GetLevel()
        end
        return 0
    end
    function hutao_com_level_sys:SetExp(exp)
        if self.classified then
            self.classified:SetExp(exp)
        end        
    end
    function hutao_com_level_sys:GetExp()
        if self.classified then
            return self.classified:GetExp()
        end
        return 0
    end
    function hutao_com_level_sys:SetExpMax(exp_max)
        if self.classified then
            self.classified:SetExpMax(exp_max)
        end        
    end
    function hutao_com_level_sys:GetExpMax()
        if self.classified then
            return self.classified:GetExpMax()
        end
        return 1
    end
------------------------------------------------------------------------------------------------------------------------------
return hutao_com_level_sys







